function open_file_menu(file_id){
  try{
    var file_menu=getElement("file_menu_"+file_id);
    file_menu.style.display=file_menu.style.display=="block"?"none":"block";
  }catch(e){
    alert("Error open_file_menu:"+e.message);
  }
}

function insert_file(field,kind,path,id,title){
  try{
    var oRTE=getElement(field).contentWindow;
    switch(kind){
      case "image"     : {oRTE.document.execCommand('InsertImage', false, "/"+path);break;}
      case "link"      : {pasteHtml(oRTE,"{file kind=\"link\" id=\""+id+"\" name=\""+path+"\" }");break;}
      case "download"  : {var desc;if(desc=prompt(title,""))pasteHtml(oRTE,"{file kind=\"download\" id=\""+id+"\" name=\""+desc+"\" }");break;}
      case "popimage"  : {var prev;if(prev=prompt(title,""))pasteHtml(oRTE,"{file kind=\"popimage\" id=\""+id+"\" preview=\""+prev+"\" }");break;}
      case "video"     : {pasteHtml(oRTE,"{file kind=\"video\" id=\""+id+"\" name=\""+path+"\" }");break;}
      case "flash"     : {pasteHtml(oRTE,"{file kind=\"flash\" id=\""+id+"\" name=\""+path+"\" }");break;}
      case "icon"      : {pasteHtml(oRTE,"{file kind=\"icon\" id=\""+id+"\" name=\""+path+"\" }");break;}
    }
    var file_menu=getElement("file_menu_"+id);
    file_menu.style.display="none";
    return false;
  }catch(e){
    alert("Error insert_file:"+e.message);
  }
}